Conclusion.setConfidence   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 1
dl 4
loc 4
rs 10
1 View Code Duplication
var GedcomX = require('../'),
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
    utils = require('../utils');
3
4
/**
5
 * An abstract concept for a basic genealogical data item.
6
 * 
7
 * @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#conclusion|GEDCOM X JSON Spec}
8
 * 
9
 * @class
10
 * @extends ExtensibleData
11
 * @param {Object} [json]
12
 */
13
var Conclusion = function(json){
14
  
15
  // Protect against forgetting the new keyword when calling the constructor
16
  if(!(this instanceof Conclusion)){
17
    return new Conclusion(json);
18
  }
19
  
20
  // If the given object is already an instance then just return it. DON'T copy it.
21
  if(Conclusion.isInstance(json)){
22
    return json;
23
  }
24
  
25
  this.init(json);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
26
};
27
28
Conclusion.prototype = Object.create(GedcomX.ExtensibleData.prototype);
29
30
Conclusion._gedxClass = Conclusion.prototype._gedxClass = 'GedcomX.Conclusion';
31
32
Conclusion.jsonProps = [
33
  'lang',
34
  'confidence',
35
  'analysis',
36
  'attribution',
37
  'sources',
38
  'notes'
39
];
40
41
/**
42
 * Check whether the given object is an instance of this class.
43
 * 
44
 * @param {Object} obj
45
 * @returns {Boolean}
46
 */
47
Conclusion.isInstance = function(obj){
48
  return utils.isInstance(obj, this._gedxClass);
49
};
50
51
/**
52
 * Initialize from JSON
53
 * 
54
 * @param {Object}
0 ignored issues
show
Documentation introduced by
The parameter * does not exist. Did you maybe forget to remove this comment?
Loading history...
55
 * @return {Conclusion} this
56
 */
57
Conclusion.prototype.init = function(json){
58
  
59
  GedcomX.ExtensibleData.prototype.init.call(this, json);
60
  
61
  if(json){
62
    this.setAttribution(json.attribution);
63
    this.setAnalysis(json.analysis);
64
    this.setConfidence(json.confidence);
65
    this.setLang(json.lang);
66
    this.setNotes(json.notes);
67
    this.setSources(json.sources);
68
  }
69
  return this;
70
};
71
72
/**
73
 * Get the attribution.
74
 * 
75
 * @returns {Attribution}
76
 */
77
Conclusion.prototype.getAttribution = function(){
78
  return this.attribution;
79
};
80
81
/**
82
 * Set the attribution
83
 * 
84
 * @param {Object|Attribution} attribution
85
 * @returns {Conclusion} This instance
86
 */
87
Conclusion.prototype.setAttribution = function(attribution){
88
  if(attribution){
89
    this.attribution = new GedcomX.Attribution(attribution);
90
  }
91
  return this;
92
};
93
94
/**
95
 * Get analysis.
96
 * 
97
 * @returns {ResourceReference} analysis
98
 */
99
Conclusion.prototype.getAnalysis = function(){
100
  return this.analysis;
101
};
102
103
/**
104
 * Set the analysis
105
 * 
106
 * @param {Object|ResourceReference} analysis
107
 * @returns {Conclusion} This instance
108
 */
109
Conclusion.prototype.setAnalysis = function(analysis){
110
  if(analysis){
111
    this.analysis = new GedcomX.ResourceReference(analysis);
112
  }
113
  return this;
114
};
115
116
/**
117
 * Get the confidence.
118
 * 
119
 * @returns {String} confidence
120
 */
121
Conclusion.prototype.getConfidence = function(){
122
  return this.confidence;
123
};
124
125
/**
126
 * Set the confidence.
127
 * 
128
 * @param {String} confidence
129
 * @returns {Conclusion} This instance
130
 */
131
Conclusion.prototype.setConfidence = function(confidence){
132
  this.confidence = confidence;
133
  return this;
134
};
135
136
/**
137
 * Get the language identifier.
138
 * 
139
 * @returns {String} lang
140
 */
141
Conclusion.prototype.getLang = function(){
142
  return this.lang;
143
};
144
145
/**
146
 * Set the language identifier.
147
 * 
148
 * @param {String} lang
149
 * @returns {Conclusion} This instance.
150
 */
151
Conclusion.prototype.setLang = function(lang){
152
  this.lang = lang;
153
  return this;
154
};
155
156
/**
157
 * Get the notes
158
 * 
159
 * @returns {Note[]} notes
160
 */
161
Conclusion.prototype.getNotes = function(){
162
  return this.notes || [];
163
};
164
165
/**
166
 * Set the notes
167
 * 
168
 * @param {Object[]|Note[]} notes
169
 * @returns {Conclusion} This instance
170
 */
171
Conclusion.prototype.setNotes = function(notes){
172
  return this._setArray(notes, 'notes', 'addNote');
173
};
174
175
/**
176
 * Add a note
177
 * 
178
 * @param {Object|Note} note
179
 * @returns {Conclusion} This instance
180
 */
181
Conclusion.prototype.addNote = function(note){
182
  return this._arrayPush(note, 'notes', GedcomX.Note);
183
};
184
185
/**
186
 * Get the sources
187
 * 
188
 * @returns {SourceReference[]}
189
 */
190
Conclusion.prototype.getSources = function(){
191
  return this.sources || [];
192
};
193
194
/**
195
 * Set the sources
196
 * 
197
 * @param {Object[]|SourceReference[]} sources
198
 * @returns {Conclusion} This instance
199
 */
200
Conclusion.prototype.setSources = function(sources){
201
  return this._setArray(sources, 'sources', 'addSource');
202
};
203
204
/**
205
 * Add a source
206
 * 
207
 * @param {SourceReference} source
208
 * @returns {Conclusion} This instance
209
 */
210
Conclusion.prototype.addSource = function(source){
211
  return this._arrayPush(source, 'sources', GedcomX.SourceReference);
212
};
213
214
/**
215
 * Export the object as JSON
216
 * 
217
 * @return {Object} JSON object
218
 */
219
Conclusion.prototype.toJSON = function(){
220
  return this._toJSON(GedcomX.ExtensibleData, Conclusion.jsonProps);
221
};
222
223
module.exports = Conclusion;